//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package org.activiti.engine.impl.persistence.entity.data.impl;

import java.util.HashMap;
import java.util.List;
import org.activiti.engine.impl.Page;
import org.activiti.engine.impl.SuspendedJobQueryImpl;
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.activiti.engine.impl.persistence.CachedEntityMatcher;
import org.activiti.engine.impl.persistence.entity.SuspendedJobEntity;
import org.activiti.engine.impl.persistence.entity.SuspendedJobEntityImpl;
import org.activiti.engine.impl.persistence.entity.data.AbstractDataManager;
import org.activiti.engine.impl.persistence.entity.data.SuspendedJobDataManager;
import org.activiti.engine.impl.persistence.entity.data.impl.cachematcher.SuspendedJobsByExecutionIdMatcher;
import org.activiti.engine.runtime.Job;

public class MybatisSuspendedJobDataManager extends AbstractDataManager<SuspendedJobEntity> implements SuspendedJobDataManager {
  protected CachedEntityMatcher<SuspendedJobEntity> suspendedJobsByExecutionIdMatcher = new SuspendedJobsByExecutionIdMatcher();

  public MybatisSuspendedJobDataManager(ProcessEngineConfigurationImpl processEngineConfiguration) {
    super(processEngineConfiguration);
  }

  public Class<? extends SuspendedJobEntity> getManagedEntityClass() {
    return SuspendedJobEntityImpl.class;
  }

  public SuspendedJobEntity create() {
    return new SuspendedJobEntityImpl();
  }

  public List<Job> findJobsByQueryCriteria(SuspendedJobQueryImpl jobQuery, Page page) {
    String query = "selectSuspendedJobByQueryCriteria";
    return this.getDbSqlSession().selectList(query, jobQuery, page);
  }

  public long findJobCountByQueryCriteria(SuspendedJobQueryImpl jobQuery) {
    return (Long)this.getDbSqlSession().selectOne("selectSuspendedJobCountByQueryCriteria", jobQuery);
  }

  public List<SuspendedJobEntity> findJobsByExecutionId(String executionId) {
    return this.getList("selectSuspendedJobsByExecutionId", executionId, this.suspendedJobsByExecutionIdMatcher, true);
  }

  public List<SuspendedJobEntity> findJobsByProcessInstanceId(String processInstanceId) {
    return this.getDbSqlSession().selectList("selectSuspendedJobsByProcessInstanceId", processInstanceId);
  }

  public void updateJobTenantIdForDeployment(String deploymentId, String newTenantId) {
    HashMap<String, Object> params = new HashMap();
    params.put("deploymentId", deploymentId);
    params.put("tenantId", newTenantId);
    this.getDbSqlSession().update("updateSuspendedJobTenantIdForDeployment", params);
  }
}
